package com.onlinefurnitureshop.customer.interceptors;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.onlinefurnitureshop.customer.model.Customer;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class CustomerLoginInterceptor extends AbstractInterceptor{

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		Map session = arg0.getInvocationContext().getSession();
		Customer customer = (Customer)session.get("customer");
		if(customer != null){
			return arg0.invoke();
		}else{
			ActionContext ac = arg0.getInvocationContext();
			return "login";
		}
	}
}
